package com.yanqu.road.server.manger.kowloon.battle.role.hero;

import com.yanqu.road.entity.kowloon.enums.battle.eKowloonBulletType;
import com.yanqu.road.entity.kowloon.enums.battle.eKowloonHeroState;
import com.yanqu.road.server.manger.kowloon.battle.KowloonGame;
import com.yanqu.road.server.manger.kowloon.battle.role.bullet.KowloonBullet;
import com.yanqu.road.server.manger.kowloon.battle.role.enemy.KowloonEnemy;

public class KowloonHero6 extends KowloonHero {

    private int attackCount = 0;

    private double bulletDegree = 90;

    public KowloonHero6(KowloonGame game) {
        super(game);
    }

    @Override
    public void attack() {
        if (this.targetEnemys != null && this.targetEnemys.size() > 0) {
            KowloonEnemy enemy = this.targetEnemys.get(0);
            if (enemy.pos.getY() >= this.pos.getY()) {
                this.bulletDegree = 90;
            } else {
                this.bulletDegree = -90;
            }
            if (this.data.getProperty().getBullet() > 1) {
                this.attackCount = this.data.getProperty().getBullet();
                this.cdNextTime = game.gameTime;
                this.stateChange(eKowloonHeroState.Attack2);
                return;
            }
            KowloonBullet.addBullet(game, eKowloonBulletType.Football, this, null, this.bulletDegree);
        }
        this.cd();
    }

    public void attack2() {
        if (game.gameTime < this.cdNextTime) {
            return;
        }
        if (this.attackCount <= 0) {
            this.cd();
            return;
        }
        KowloonBullet.addBullet(game, eKowloonBulletType.Football, this, null, this.bulletDegree);
        this.attackCount--;
        this.cdNextTime = game.gameTime + 100;
    }
}
